﻿



using QLua;

namespace QLuaApp;

public class PP
{
    public double Age {  get; set; }
    public void SetAge(int age) => Age=age;
}

[LuaExport]
public static class MathHelper
{
    
    [LuaMethod]
    public static int Add(int a, int b) => a + b;
}
internal class Program
{
	public static int Add (int a, int b) => a + b;
	static void Main(string[] args)
    {
        
        Lua  lua = new Lua();
        
		QLua.Common.LuaAutoRegistrar.RegisterAll(lua);
        var pp=new PP();
        lua.RegisterFunction("SetAge", pp, typeof(PP).GetMethod("SetAge"));
		lua.DoString("print(Add(1,2))");
		lua.DoString("print(SetAge(20))");
        Console.WriteLine($"the age is {pp.Age}");
		lua["Math"] = typeof(MathHelper);
		lua.DoString("print(Math.GetType())");


		Console.WriteLine("Hello, World!");
    }
}
